const path = require('path');
const resolve = (dir) => path.join(__dirname, dir);

module.exports = {
    publicPath: './', // default:'/'
    outputDir: 'dist',
    assetsDir: 'static',  // static resources(js, css, img, fonts)
    lintOnSave: false,// close eslint
    runtimeCompiler: true,
    productionSourceMap: false,// separate CSS files
    parallel: require('os').cpus().length > 1,
    pwa: {},
    devServer: {
        proxy: {
            '/api': {
                target: 'https://localhost:8443/',
                changeOrigin: true,
                pathRewrite: {
                    '^/api': ''
                },
                // timeout: 60000000
            }
        }
    },
    chainWebpack: config => {
        // chunks
        config.optimization
            .splitChunks({
                cacheGroups: {}
            });
        // add alias
        config.resolve.alias
            .set('@', resolve('src'))
            .set('assets', resolve('src/assets'))
            .set('components', resolve('src/components'))
            .set('views', resolve('src/views'))
            .set('services', resolve('src/services'))
            .set('util', resolve('src/util'));
    }
};
